package com.byit.Test.Mytest1.ProducerAndConsumer;

/**
 * @ClassName Producer
 * @Description TODO
 * @Author lxp
 * @Date 2018/10/9 0009
 **/
public class Producer implements Runnable {

    //定义一个静态的变量存放产品
    public static int count = 0;

    Repertory repertory = null;

    public Producer(Repertory repertory) {
        this.repertory = repertory;
    }

    @Override
    public void run() {

        while (true){
            synchronized (Producer.class){
                count++;
                Product p = new Product(count);
                repertory.push(p,Thread.currentThread().getName());
            }
        }
    }
}
